import request from '@/utils/request.js'
import { useTokenStore } from '@/stores/token.js'
//考试分类列表查询
// export const examCategoryListService = ()=>{
//     //const tokenStore = useTokenStore();
//     //在pinia中定义的响应式数据,都不需要.value
//     //return request.get('/category',{headers:{'Authorization':tokenStore.token}})
//     return request.get('/category')
// }

//考试列表查询
export const examListService = ()=>{
   return  request.get('/exam')
}

//为考生服务的考试列表查询
export const examListForStudentService = (s_id)=>{
    // 根据考生学号返回该考生的考试列表
    return  request.get(`/exam'?s_id=${s_id}`)
}

//考试添加
export const examAddService = (examData)=>{
    return request.post('/exam',examData);
}

// 更新考试信息
export const examUpdateService = (examData) => {
    return request.put('/exam', examData);
};

// 删除考试
export const examDeleteService = (id) => {
    return request.delete(`/exam?id=${id}`);
};

// 根据部分信息查询考试,返回符合条件的考试列表(因为考试名称非唯一标识，可能重复)
export const examSearchService = (e_name)=>{
    return  request.get(`/exam?e_name=${e_name}`)
}

// 为考生服务的根据部分信息查询考试,返回符合条件的考试列表(因为考试名称非唯一标识，可能重复)
// const searchExamData = ref({
//     s_id: my_s_id.value,
//     e_name: ''
// })
export const examSearchForStudentService = (searchExamData)=>{
    return  request.get('/exam/studentSearch',searchExamData)
}

// 下载考试归档
export const examDownloadZipService = (id) => {
    return request.get(`/exam/download/${id}`, { responseType: 'blob' });
};


// 考试状态查询
export const examStatusService = (id) => {
    return request.get(`/exam/status/${id}`);
};

